package com.ieheima.zuoye1;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Test {
    public static void main(String[] args) {
        String[] provinces = {"河北省", "山西省", "吉林省", "辽宁省",
                "黑龙江省", "陕西省", "甘肃省", "青海省", "山东省", "福建省", "浙江省",
                "台湾省", "河南省", "湖北省", "湖南省", "江西省", "江苏省", "安徽省",
                "广东省", "海南省", "四川省", "贵州省", "云南省", "北京市", "天津市",
                "上海市", "重庆市", "内蒙古自治区", "新疆维吾尔自治区", "宁夏回族自治区",
                "广西壮族自治区", "西藏自治区", "香港特别行政区", "澳门特别行政区"};
        long count = Arrays.stream(provinces).filter(p -> p.length() == 3)
                .count();
        System.out.println("三个的省份的个数："+count);
        long count1 = Arrays.stream(provinces).filter(p -> p.contains("南")
                || p.contains("北") || p.contains("东") || p.contains("西")).count();
        System.out.println("有南、北、东、西的省份的个数："+count1);


        System.out.println("==================");
        Arrays.stream( provinces).filter(p ->( p.contains("南")
                || p.contains("北") || p.contains("东") || p.contains("西") ) && p.contains("省"))
                .forEach(System.out::println);
        Object[] array = Arrays.stream(provinces).filter(
                p -> (p.contains("市") || p.contains("自治区") || p.contains("特别行政区"))
        ).toArray();
        System.out.println("==================");
        Arrays.stream(array).forEach(System.out::println);


    }
}
